<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style type="text/css">
        .safe-close {
            position: absolute;
            top: 10px;
            left: 10px;
        }

        .safe-close button {
            color: red;
        }
    </style>
</head>
<body onclick="setFocus()" onload="setFocus()">
    <div class="safe-close">
        <button onclick="javascript:window.open('?vncid={{ vncid }}&close=1', '_self')">关闭</button>
    </div>
    <div>
        <iframe id="novnc" src="{{ url }} " width="100%" onload="setHeight()" align="center"></iframe>
    </div>
    <script type="text/javascript">
        function setFocus() {
            document.getElementById("novnc").focus();
        }

        function setHeight() {
            var ifm = document.getElementById("novnc");
            var old = ifm.height;
            var now = document.documentElement.clientHeight;
            if (now > old){
                ifm.height = now;
            }
        }
        window.onresize = function () {
            setHeight();
        }
    </script>
</body>
</html>